package com.freesky.biz.abchina.controller;

import com.freesky.biz.abchina.domain.TStagesRecord;
import com.freesky.biz.abchina.service.IStagesRecordService;
import com.freesky.common.annotation.Log;
import com.freesky.common.core.controller.BaseController;
import com.freesky.common.core.domain.AjaxResult;
import com.freesky.common.core.page.TableDataInfo;
import com.freesky.common.enums.BusinessType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

@RestController
@RequestMapping("/abchina/stages/")
public class StagesRecordController extends BaseController {

    @Autowired
    private IStagesRecordService stagesRecordService;

    /**
     * 乐分期列表
     */
    @PreAuthorize("@ss.hasPermi('abchina:stages:list')")
    @GetMapping("/list")
    public TableDataInfo list(TStagesRecord stagesRecord) {
        startPage();
        List<TStagesRecord> list = stagesRecordService.findList(stagesRecord);
        return getDataTable(list);
    }

    @Log(title = "乐分期", businessType = BusinessType.EXPORT)
    @PreAuthorize("@ss.hasPermi('abchina:stages:export')")
    @GetMapping("/export")
    public AjaxResult export(TStagesRecord stagesRecord,
                             HttpServletResponse response) {
        return stagesRecordService.exportFile(stagesRecord);
    }

}
